[AIT-681] Compute fork metadata for edits via useChat#37
Open
lawrence-forooghian wants to merge 2 commits intomainfrom
Open
[AIT-681] Compute fork metadata for edits via useChat#37lawrence-forooghian wants to merge 2 commits intomainfrom
useChat#37lawrence-forooghian wants to merge 2 commits intomainfrom
Conversation
useChat
useChatuseChat
310350c to
537fc2f
Compare
537fc2f to
84a1346
Compare
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||
84a1346 to
f1815e4
Compare
f1815e4 to
c37bb72
Compare
kaschula
approved these changes
Apr 14, 2026
Contributor
kaschula
left a comment
There was a problem hiding this comment.
Looks great. I have tested on your demo branch.
I do have a question. Do you plan to merge you demo or integrate the edit functionality into the current demos?
Contributor
Author
I hadn't planned to; do you think it would be useful? |
c37bb72 to
2874307
Compare
Our SDK has two forking operations: edit (replace a user message) and regenerate (re-run an assistant message). The AI SDK's useChat exposes the same two: sendMessage with a messageId (edit) [1] and regenerate(). We already made our regenerate compatible with useChat's — ChatTransport computes forkOf/parent from the conversation tree when trigger is 'regenerate-message'. It turns out we missed the edit case. Without fork metadata, edits via useChat were treated as new messages rather than forks in the conversation tree. We fix it by always including fork metadata when the messageId is provided, regardless of the trigger, thus continuing to cover the regeneration case and now also the edit case. [1] https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat#send-message [AIT-681] Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2874307 to
8cc3b51
Compare
Wire useChat's sendMessage({ messageId }) through the demo UI so that
user messages can be edited inline. Clicking "edit" on a user bubble
opens a textarea pre-filled with the original text; "Save & send"
calls sendMessage with the messageId, triggering the submit-message
edit flow through ChatTransport.
Not yet tested — intended to be squashed into the preceding commit
(8cc3b51) once verified.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Our SDK has two forking operations: edit (replace a user message) and regenerate (re-run an assistant message). The AI SDK's
useChatexposes the same two:sendMessagewith amessageId(edit) andregenerate(). We already made our regenerate compatible withuseChat's —ChatTransportcomputesforkOf/parentfrom the conversation tree when trigger isregenerate-message.It turns out we missed the edit case. Without fork metadata, edits via
useChatwere treated as new messages rather than forks in the conversation tree.We fix it by always including fork metadata when the
messageIdis provided, regardless of the presence of atrigger, thus continuing to cover the regeneration case and now also the edit case.Demo
The demo app used for the videos below is on a separate branch:
AIT-681-edit-demo(demo/vercel/react/edit-demo/).Normal
useChatedit (plain Vercel, no Ably transport)2026-04-10.16-56-51.mov
useChatedit with our transport — before fix (broken)2026-04-10.17-00-19.mov
useChatedit with our transport — after fix (working)2026-04-10.17-06-03.mov
AIT-681
🤖 Generated with Claude Code